package 如何初始化数组;

public class 数组反转20 {
	public static void main(String[] args) {
		 
        int[] array = new int[5];
		int temp = 0;
		 
		// 生成随机数列
		for (int i = 0; i < array.length; i++) {
		    array[i] = (int)(Math.random()*100);
		    System.out.print(array[i]+" ");
		}
		
		// 实现数组反转
		for (int i = 0; i < array.length/2; i++) {
		    temp = array[i];
		    array[i] = array[array.length-i-1];
		    array[array.length-i-1] = temp;
		}
		System.out.println("\n"+"反转数组遍历");
		
		// 输出反转数组
		for (int s : array) {
		    System.out.print(s+" ");
		    }
		}
}